package com.example.mydemo2;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Context;
import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

public class OdersListRecycleActivity extends AppCompatActivity {
    private Context context;
    private List<OrdersItem> ordersItems = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_oders_list_recycle);
        RecyclerView recyclerView = findViewById(R.id.orders_list_view);
        context = this;

        //1.指定表现形式
        //列表  目前是处于滚动
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        //实现水平滚动
        recyclerView.setLayoutManager(linearLayoutManager);
        //网格  这两种常用
        //GridLayoutManager gridLayoutManager = new GridLayoutManager(context,2);

        //2.自定义适配器
        OrdersListAdapter ordersListAdapter = new OrdersListAdapter();
        recyclerView.setAdapter(ordersListAdapter);

        //3.设置数据
        initData();
        ordersListAdapter.setData(ordersItems);


    }

    public void initData(){

        OrdersItem ordersItem = new OrdersItem();
        ordersItem.setOrderDate("2200-04-09      12:00");
        ordersItem.setSalePeople("小呆呆");
        ordersItem.setRecyclePeople("小呆呆");
        ordersItem.setThingType("小呆呆");
        ordersItem.setTotalCount(1000);
        ordersItem.setPrice(9999);
        ordersItem.setTotal(8888);
        ordersItems.add(ordersItem);

        OrdersItem ordersItem1 = new OrdersItem();
        ordersItem1.setOrderDate("2200-04-09      12:00");
        ordersItem1.setSalePeople("小呆呆");
        ordersItem1.setRecyclePeople("小呆呆");
        ordersItem1.setThingType("小呆呆");
        ordersItem1.setTotalCount(1000);
        ordersItem1.setPrice(9999);
        ordersItem1.setTotal(8888);
        ordersItems.add(ordersItem1);

        OrdersItem ordersItem12 = new OrdersItem();
        ordersItem12.setOrderDate("2200-04-09      12:00");
        ordersItem12.setSalePeople("小呆呆");
        ordersItem12.setRecyclePeople("小呆呆");
        ordersItem12.setThingType("小呆呆");
        ordersItem12.setTotalCount(1000);
        ordersItem12.setPrice(9999);
        ordersItem12.setTotal(8888);
        ordersItems.add(ordersItem12);

        OrdersItem ordersItem2 = new OrdersItem();
        ordersItem2.setOrderDate("2200-04-09      12:00");
        ordersItem2.setSalePeople("小呆呆");
        ordersItem2.setRecyclePeople("小呆呆");
        ordersItem2.setThingType("小呆呆");
        ordersItem2.setTotalCount(1000);
        ordersItem2.setPrice(9999);
        ordersItem2.setTotal(8888);
        ordersItems.add(ordersItem2);



    }



}